home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / Debconf / FrontEnd / Gnome.pm < prev    next >
Encoding:
Perl POD Document  |  2009-03-24  |  3.8 KB  |  185 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd::Gnome;
  6. use strict;
  7. use utf8;
  8. use Debconf::Gettext;
  9. use Debconf::Config;
  10. use Debconf::Encoding qw(to_Unicode);
  11. use base qw{Debconf::FrontEnd};
  12.  
  13. eval q{
  14.     use Gtk2;
  15.     use Gnome2;
  16. };
  17. die "Unable to load Gnome -- is libgnome2-perl installed?\n" if $@;
  18.  
  19.  
  20. our @ARGV_for_gnome=('--sm-disable');
  21.  
  22. sub create_druid_page {
  23.     my $this=shift;
  24.     
  25.        $this->druid_page(Gnome2::DruidPageStandard->new);
  26.     $this->druid_page->set_logo($this->logo);
  27.     $this->druid_page->signal_connect("back", sub {
  28.         $this->goback(1);
  29.         Gtk2->main_quit;
  30.         return 1;
  31.     });
  32.     $this->druid_page->signal_connect("next", sub {
  33.         $this->goback(0);
  34.         Gtk2->main_quit;
  35.         return 1;
  36.     });
  37.     $this->druid_page->signal_connect("cancel", sub { exit 1 });
  38.     $this->druid_page->show;
  39.     $this->druid->append_page($this->druid_page);
  40.     $this->druid->set_page($this->druid_page);
  41. }
  42.  
  43. sub init {
  44.     my $this=shift;
  45.     
  46.     if (fork) {
  47.         wait(); # for child
  48.         if ($? != 0) {
  49.             die "DISPLAY problem?\n";
  50.         }
  51.     }
  52.     else {
  53.         @ARGV=@ARGV_for_gnome; # temporary change at first
  54.         Gnome2::Program->init('GNOME Debconf', '2.0');
  55.         exit(0); # success
  56.     }
  57.     
  58.     my @gnome_sucks=@ARGV;
  59.     @ARGV=@ARGV_for_gnome;
  60.     Gnome2::Program->init('GNOME Debconf', '2.0');
  61.     @ARGV=@gnome_sucks;
  62.     
  63.     $this->SUPER::init(@_);
  64.     $this->interactive(1);
  65.     $this->capb('backup');
  66.     $this->need_tty(0);
  67.     
  68.     $this->win(Gtk2::Window->new("toplevel"));
  69.     $this->win->set_position("center");
  70.     $this->win->set_default_size(600, 400);
  71.     my $hostname = `hostname`;
  72.     chomp $hostname;
  73.     $this->win->set_title(to_Unicode(sprintf(gettext("Debconf on %s"), $hostname)));
  74.     $this->win->signal_connect("delete_event", sub { exit 1 });
  75.     
  76.     my $distribution='';
  77.     if (system('type lsb_release >/dev/null 2>&1') == 0) {
  78.         $distribution=lc(`lsb_release -is`);
  79.         chomp $distribution;
  80.     } elsif (-e '/etc/debian_version') {
  81.         $distribution='debian';
  82.     }
  83.  
  84.     my $logo="/usr/share/pixmaps/$distribution-logo.png";
  85.     if (-e $logo) {
  86.         $this->logo(Gtk2::Gdk::Pixbuf->new_from_file($logo));
  87.     }
  88.     
  89.     $this->druid(Gnome2::Druid->new);
  90.     if ( $ENV{"RELEASE_UPGRADE_IN_PROGRESS"} ) {
  91.         $this->druid->cancel->hide;
  92.         $this->win->signal_connect("realize", sub { $this->win->window->set_functions(["resize","move","maximize"]) });
  93.     }
  94.     $this->druid->show;
  95.     $this->win->add($this->druid);
  96.     
  97.     $this->create_druid_page ();
  98. }
  99.  
  100.  
  101. sub go {
  102.         my $this=shift;
  103.     my @elements=@{$this->elements};
  104.     
  105.     my $interactive='';
  106.     foreach my $element (@elements) {
  107.         next unless $element->hbox;
  108.  
  109.         $interactive=1;
  110.         $this->druid_page->vbox->pack_start($element->hbox, $element->fill, $element->expand, 0);
  111.     }
  112.  
  113.     if ($interactive) {
  114.             $this->druid_page->set_title(to_Unicode($this->title));
  115.         if ($this->capb_backup) {
  116.             $this->druid->set_buttons_sensitive(1, 1, 1, 1);
  117.         }
  118.         else {
  119.             $this->druid->set_buttons_sensitive(0, 1, 1, 1);
  120.         }
  121.         $this->win->show;
  122.         Gtk2->main;
  123.         $this->create_druid_page ();
  124.     }
  125.  
  126.     foreach my $element (@elements) {
  127.         $element->show;
  128.     }
  129.  
  130.     return '' if $this->goback;
  131.     return 1;
  132. }
  133.  
  134. sub progress_start {
  135.     my $this=shift;
  136.     $this->SUPER::progress_start(@_);
  137.  
  138.     my $element=$this->progress_bar;
  139.     $this->druid_page->vbox->pack_start($element->hbox, $element->fill, $element->expand, 0);
  140.     $this->druid_page->set_title(to_Unicode($this->title));
  141.     $this->druid->set_buttons_sensitive(0, 0, 1, 1);
  142.     $this->win->show;
  143.  
  144.     while (Gtk2->events_pending) {
  145.         Gtk2->main_iteration;
  146.     }
  147. }
  148.  
  149. sub progress_set {
  150.     my $this=shift;
  151.  
  152.     my $ret=$this->SUPER::progress_set(@_);
  153.  
  154.     while (Gtk2->events_pending) {
  155.         Gtk2->main_iteration;
  156.     }
  157.  
  158.     return $ret;
  159. }
  160.  
  161. sub progress_info {
  162.     my $this=shift;
  163.     my $ret=$this->SUPER::progress_info(@_);
  164.  
  165.     while (Gtk2->events_pending) {
  166.         Gtk2->main_iteration;
  167.     }
  168.  
  169.     return $ret;
  170. }
  171.  
  172. sub progress_stop {
  173.     my $this=shift;
  174.     $this->SUPER::progress_stop(@_);
  175.  
  176.     while (Gtk2->events_pending) {
  177.         Gtk2->main_iteration;
  178.     }
  179.  
  180.     $this->create_druid_page();
  181. }
  182.  
  183.  
  184. 1
  185.